<?php

$smarty->configLoad($lang . '/options.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['options'];

$sql = 'SELECT * FROM ' . DB_CMS . '.website_modules ORDER BY access_level ASC';
$dbh = $connection->query($sql);
foreach ($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
	$row['access'] = $main->getRights($row['access_level']);
	$value[] = $row;
}
$smarty->assign('value', $value);

$sql = 'SELECT * FROM ' . DB_CMS . '.website_access_levels';
$dbh = $connection->query($sql);
$i = 1;
$right = '';
foreach ($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
	$right .= '<option value="' . $row['access_level'] . '">' . $row['title'] . '</option>';
	$json[$i] = $row['title'];
	$i++;
}
$smarty->assign('right', $right);
$json_rights = json_encode($json);
$smarty->assign('json_rights', $json_rights);
$template = 'options/modules.tpl';
if (isset($_POST['add'])) {
	$sql = 'INSERT INTO ' . DB_CMS . '.website_modules (title, access_level, licencekey, module) VALUES (:title, :access, :licence, :module)';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':title', $_POST['title']);
	$dbh->bindValue(':access', $_POST['access']);
	$dbh->bindValue(':licence', $_POST['licence']);
	$dbh->bindValue(':module', $_POST['name']);
	$dbh->execute();
}
?>
 